//
//  LoginView.m
//  豆瓣HW
//
//  Created by dllo on 15/11/26.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "LoginView.h"


@implementation LoginView

- (void)dealloc
{
    [_label1 release];
    [_label2 release];
    [_textF1 release];
    [_textF2 release];
    [_button1 release];
    [_button2 release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self credateSubviews];
    }
    return self;
}

- (void)credateSubviews
{
    self.backgroundColor = [UIColor whiteColor];

    self.label1 = [[UILabel alloc] initWithFrame:CGRectMake(50, 130, 60, 30)];
    self.label1.text = @"用户名:";
    [self addSubview:self.label1];
    [_label1 release];
    
    self.label2 = [[UILabel alloc] initWithFrame:CGRectMake(50, self.label1.frame.origin.y + self.label1.frame.size.height + 30, 60, 30)];
    self.label2.text = @"密码:";
    [self addSubview:self.label2];
    [_label2 release];
    
    self.textF1 = [[UITextField alloc] initWithFrame:CGRectMake(self.label1.frame.origin.x + self.label1.frame.size.width + 20, self.label1.frame.origin.y, 180, 30)];
    self.textF1.placeholder = @"请输入用户名";
    self.textF1.borderStyle = UITextBorderStyleRoundedRect;
    [self addSubview:self.textF1];
    [_textF1 release];

    self.textF2 = [[UITextField alloc] initWithFrame:CGRectMake(self.label2.frame.origin.x + self.label2.frame.size.width + 20, self.label2.frame.origin.y, 180, 30)];
    self.textF2.placeholder = @"请输入密码";
    self.textF2.borderStyle = UITextBorderStyleRoundedRect;
    [self addSubview:self.textF2];
    [_textF2 release];
    
    self.button1 = [UIButton buttonWithType:UIButtonTypeCustom];
    self.button1.frame = CGRectMake(self.label1.frame.origin.x, self.label2.frame.origin.y + self.label2.frame.size.height + 40, 120, 40);
    self.button1.backgroundColor = [UIColor blackColor];
    [self.button1 setTitle:@"登陆" forState:UIControlStateNormal];
    [self.button1 addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.button1];
    
    self.button2 = [UIButton buttonWithType:UIButtonTypeCustom];
    self.button2.frame = CGRectMake(self.label1.frame.origin.x + self.button1.frame.size.width + 20, self.label2.frame.origin.y + self.label2.frame.size.height + 40, 120, 40);
    [self.button2 setTitle:@"注册" forState:UIControlStateNormal];
    [self.button2 addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    self.button2.backgroundColor = [UIColor blackColor];
    
    [self addSubview:self.button2];
    
    
    
}

- (void)buttonAction:(UIButton *)sender
{
    if (sender == self.button2) {
        [self.delegate preshButton];
    }
}

@end
